package com.tupi.project.ui.activity;

import android.content.Intent;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.tupi.project.R;
import com.tupi.project.base.BaseActivity;
import com.tupi.project.ui.adapter.MainAdapter;
import com.tupi.project.ui.contract.MainContract;
import com.tupi.project.ui.presenter.MainPresenter;

import java.util.Arrays;
import java.util.List;

import butterknife.BindView;

public class MainActivity extends BaseActivity<MainPresenter> implements MainContract.View
{
    @BindView(R.id.recycler_view)
    RecyclerView mRecyclerView;
    
    @Override
    protected void initInject()
    {
        getActivityComponent().inject(this);
    }
    
    @Override
    protected int getLayout()
    {
        return R.layout.activity_main;
    }
    
    @Override
    protected void initEventAndData()
    {
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager
                .VERTICAL, false));
        List<String> list = Arrays.asList(getResources().getStringArray
                (R.array.main_item));
        MainAdapter adapter = new MainAdapter(this, list, new MainAdapter.Inf()
        {
            @Override
            public void onItemClick(String title)
            {
                toActivity(title);
            }
        });
        mRecyclerView.setAdapter(adapter);
        
    }
    
    
    private void toActivity(String title)
    {
        switch (title)
        {
            case "Http请求":
                startActivity(new Intent(this, HttpActivity.class));
                break;
            case "权限":
                startActivity(new Intent(this, PermissionActivity.class));
                break;
            case "rxbus":
                startActivity(new Intent(this, RxBusActivity.class));
                break;
            case "下拉刷新":
                startActivity(new Intent(this, PullToRefreshActivity.class));
                break;
        }
    }
    
    
}
